<?php
include "fonctions.php";
head_html("login");
bandeau_html();

if (isset($_POST['bouton']))
{
	db_connect();
	$req = "SELECT * FROM utilisateurs WHERE pseudo='".$_POST['ident']."' ;";
	$res = mysql_query($req) or die (mysql_error());
	$nb = mysql_num_rows($res);
	if ($nb == 0)
	{
		echo "Pseudo non existant";
	}
	
	$mdp = $_POST['ident']."ov(k4G(y|ypSDWC".$_POST['mdp']."TO92|Q+5R5E9=8";
	$mdp1 = hash('sha256',$mdp);
	
	$res = (mysql_fetch_array($res));
	if ($res['mdp'] == $mdp1)
	{
		$_SESSION['idUtil'] = $_POST['ident'];
		echo '<meta http-equiv="Refresh" content="0;url=\'index.php\'" />';
	}
	else
	{
		echo 'nok';
	}
	
	
}
?>
<div id="contenu">
	<div id = "connexion">
		<form action="connexion.php" method="post">
		<label for="ident">Identifiant: </label>
		<input type="text" name="ident" /><br/><br/>

		<label for="mdp">Mot de passe: </label>
		<input type="password" name="mdp" /><br/><br/>

		<div id="boutonValider">
			<br/>
			<input type="submit" name="bouton" value="Valider"/>
		</div>
		</form>
	</div>

<?php

echo "</div>";
pied_page();
?>